/**
 *****************************************************************************
 * DESC ：. 
 * Author : Junwei Zhang 
 * CREATEDATE ：2012-8-24 
 * MODIFYLIST ：       	Name 			 Date 			Reason/Contents
 * 				------------------------------------------------------ 
 * 				 	Junwei Zhang     2012-8-24		Created.
 ****************************************************************************
 **/
package com.me.test.threadpool.phinecos;

/**
 * 
 * <br/>
 * 上午9:09:21 2012-8-24
 * 
 * @Author <a href="mailto:mestudying@sina.com">Junwei Zhang</a><br/>
 **/
public class ThreadPoolTester {

	public static void main(String[] args) {

		System.out.println("Testing ThreadPool ");
		System.out.println("Creating ThreadPool ");

		ThreadPool pool = ThreadPool.instance();
		pool.setDebug(true);

		class TestRunner implements Runnable {

			public int count = 0;

			public void run() {
				System.out.println("Testrunner sleeping 5 seconds ");
				// 此方法使本线程睡眠5秒
				synchronized (this) {
					try {
						wait(5000);// 等待5秒时间
					} catch (InterruptedException ioe) {

					}
				}
				System.out.println("Testrunner leaving");
				count++;
			}
		}

		System.out.println("Starting a new thread ");
		TestRunner runner = new TestRunner();
		pool.start(runner, ThreadPool.HIGH_PRIORITY);
		System.out.println("count : " + runner.count);
		System.out.println("Thread count : " + pool.getCreatedThreadsCount());
		pool.shutdown();

	}

}
